<template>
	<view class="content">
		<view class="login-form">
			<view style="height: 180rpx;"></view>
			<view class="uni-form-item uni-column po">
				<input class="uni-input" v-model="passwd" password type="text" placeholder-style="color:#cacaca" placeholder="请输入原密码" />
			</view>
			<view class="uni-form-item uni-column po">
				<input class="uni-input" v-model="passwd_new" password type="text" placeholder-style="color:#cacaca" placeholder="请输入新密码" />
			</view>
			<view class="uni-form-item uni-column po">
				<input class="uni-input" v-model="passwd_repetition" password type="text" placeholder-style="color:#cacaca" placeholder="请再次输入新密码" />
			</view>
			<view class="login-form-checkbox">
				<text class="login-form-link" @click="reset">忘记旧密码？</text>		
			</view>
			<view class="">
				<view class="login-form-btn" @click="post">提交</view>				
			</view>
		</view>
	</view>
</template>

<script>
	import {
        mapState,
        mapMutations
    } from 'vuex'
	
	export default {
		computed: {
			...mapState(['version','SystemInfo','token'])
		},
		data() {
			return {
				passwd_repetition: '',
				passwd_new: '',
				passwd: '',
			}
		},
		methods: {
			...mapMutations(['getNetworkType','vuexRequest','login','logout']),
			post() {
				
				if(!this.passwd){ 
					uni.showToast({
						icon: 'none',
						title: "请输入原密码",
						position:'bottom'
					})
					return false; 
				}
				if(!this.passwd_new){
					uni.showToast({
						icon: 'none',
						title: "请输入新密码",
						position:'bottom'
					})
					return false; 
				}
				if(!this.passwd_repetition){
					uni.showToast({
						icon: 'none',
						title: "请输入重复新密码",
						position:'bottom'
					})
					return false; 
				}
				uni.showLoading({
					title: '加载中'
				});
				
				// 默认信息
				let data = {passwd:this.passwd,passwd_new:this.passwd_new,passwd_repetition:this.passwd_repetition}
				
				this.vuexRequest({
					url: '/api/v2/member/member/up-password?access-token=' + this.token,
					method: 'POST',
					data: data,
					success: (res)  => {
						uni.showToast({
							icon: 'none',
							title: '修改成功',
							position:'bottom'
						})
						
						uni.navigateBack({
							
						})
					},
					fail: (err)  => {
						uni.hideLoading()
						uni.showToast({
							icon: 'none',
							title: err.data.message,
							position:'bottom'
						})
					},
				})
			},
			reset() {
				uni.navigateTo({
					url: '/pages/login/reset/reset'
				});
			}
		}
	}
</script>

<style>
	page{
		background: #FFFFFF;
	}
	.tips{
		text-align: center;
		font-size: 26upx;
		color: #e83e41;
		margin: 0 0 30upx 0 ;
	}
	.po{
		position: relative;
	}
	.po:after{
		position: absolute;
		z-index: 10;
		right: 0;
		bottom: 0;
		left: 0;
		height: 1px;
		content: '';
		-webkit-transform: scaleY(.5);
		-ms-transform: scaleY(.5);
		transform: scaleY(.5);
		background-color: #c8c7cc;
	}
	.login-logo{
		text-align: center;
		padding: 60upx 0;
	}
	.login-logo-image{
		width: 153upx;
		height: 149upx;
		margin: 0 auto;
	}
	.login-form{
		width: 85%;
		margin: 0 auto;
	}
	.uni-input{
		padding-left: 0;
	}
	
	.login-form-checkbox {
		display: flex;
		padding:  20upx 0 0 0;
		font-size: 24upx;
		color: #cacaca;
		display: inline-flex;
	}
	uni-checkbox-group uni-label{
		padding: 0;
	}
	uni-radio-group, uni-checkbox-group{
		width: auto;
	}
	.login-form-link{
		color: #e83e41;
	}
	.login-form-btn{
		margin-top: 80upx;
		background: ;
		background-image: linear-gradient(to right, #f27072, #ea4a4c);
		text-align: center;
		border-radius: 200upx;
		height: 80upx;
		line-height: 80upx;
		font-size: 32upx;
		color: #FFFFFF;
	}
	.login-form-btn.disabled{
		background: #f09596;
	}
	.login-form-tips{
		padding-top: 40upx;
		text-align: center;
		color: #979797;
	}
	.login-form-code-btn{
		position: absolute;
		right: 0;
		top: 50%;
		color: #979797;
		margin-top: -30upx;
		font-size: 28upx;
		display: block;
		width: 180upx;
		height: 60upx;
		z-index: 10;
		line-height: 60upx;
		text-align: center;
	}
	.login-form-code-btn.disabled{
		color: #cacaca;
	}
</style>
